<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 25] 25.51 java.lang.Runtime (JDK 1.0)</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:27:31 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_50.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 25<br>The java.lang Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch25_52.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-51">25.51 java.lang.Runtime (JDK 1.0)</A></h2>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-51.1"></A></h3>
</DIV>

<P CLASS=para>
This class encapsulates a number of platform-dependent
system functions. The static method
<tt CLASS=literal>getRuntime()</tt> returns the <tt CLASS=literal>Runtime</tt> object
for the current platform, and this object can be used
to perform system functions in a platform-independent
way.

<P CLASS=para>
<tt CLASS=literal>exec()</tt> starts a new process running externally to
the interpreter. Note that any processes run outside of
Java may be system-dependent.

<P CLASS=para>
<tt CLASS=literal>exit()</tt> causes the Java interpreter to exit and
return a specified return code.

<P CLASS=para>
<tt CLASS=literal>freeMemory()</tt> returns the approximate amount of free
memory. <tt CLASS=literal>totalMemory()</tt> returns the total amount of
memory available to the Java interpreter. <tt CLASS=literal>gc()</tt>
forces the garbage collector to run synchronously, which may
free up more memory. Similarly, <tt CLASS=literal>runFinalization()</tt>
forces the <tt CLASS=literal>finalize()</tt> methods of unreferenced
objects to be run immediately. This may free up system
resources that those objects were holding.

<P CLASS=para>
<tt CLASS=literal>load()</tt> loads a dynamic library with a fully
specified path name. <tt CLASS=literal>loadLibrary()</tt> loads a dynamic
library with only the library name specified; it looks in
platform-dependent locations for the specified library.
These libraries generally contain native code definitions
for native methods.

<P CLASS=para>
<tt CLASS=literal>traceInstructions()</tt> and <tt CLASS=literal>traceMethodCalls()</tt>
enable and disable tracing by the interpreter.

<P CLASS=para>
Note that some of the <tt CLASS=literal>Runtime</tt> methods are
more commonly called via the static methods of the
<tt CLASS=literal>System</tt> class.

<DIV CLASS=screen>
<P>
<PRE>
public class <tt CLASS=literal>Runtime</tt> extends Object {
    // <tt CLASS=literal>No Constructor</tt>
    // <tt CLASS=literal>Class Methods</tt>
            public static Runtime <tt CLASS=literal>getRuntime</tt>();
        <b>1.1</b>public static void <tt CLASS=literal>runFinalizersOnExit</tt>(boolean <tt CLASS=literal>value</tt>);
    // <tt CLASS=literal>Public Instance Methods</tt>
            public Process <tt CLASS=literal>exec</tt>(String <tt CLASS=literal>command</tt>) throws IOException;
            public Process <tt CLASS=literal>exec</tt>(String <tt CLASS=literal>command</tt>, String[] <tt CLASS=literal>envp</tt>) throws IOException;
            public Process <tt CLASS=literal>exec</tt>(String[] <tt CLASS=literal>cmdarray</tt>) throws IOException;
            public Process <tt CLASS=literal>exec</tt>(String[] <tt CLASS=literal>cmdarray</tt>, String[] <tt CLASS=literal>envp</tt>) throws IOException;
            public void <tt CLASS=literal>exit</tt>(int <tt CLASS=literal>status</tt>);
            public native long <tt CLASS=literal>freeMemory</tt>();
            public native void <tt CLASS=literal>gc</tt>();
        #   public InputStream <tt CLASS=literal>getLocalizedInputStream</tt>(InputStream <tt CLASS=literal>in</tt>);
        #   public OutputStream <tt CLASS=literal>getLocalizedOutputStream</tt>(OutputStream <tt CLASS=literal>out</tt>);
            public synchronized void <tt CLASS=literal>load</tt>(String <tt CLASS=literal>filename</tt>);
            public synchronized void <tt CLASS=literal>loadLibrary</tt>(String <tt CLASS=literal>libname</tt>);
            public native void <tt CLASS=literal>runFinalization</tt>();
            public native long <tt CLASS=literal>totalMemory</tt>();
            public native void <tt CLASS=literal>traceInstructions</tt>(boolean <tt CLASS=literal>on</tt>);
            public native void <tt CLASS=literal>traceMethodCalls</tt>(boolean <tt CLASS=literal>on</tt>);
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-51.2">Returned By:</A></h3>

<P CLASS=para>
Runtime.getRuntime()

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_50.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch25_52.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>java.lang.Runnable (JDK 1.0)</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.lang.RuntimeException (JDK 1.0)</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
